//
//  ActivityCallUpViewController.m
//  wtshoppingcite
//
//  Created by Baojia-LC on 14/11/10.
//  Copyright (c) 2014年 TW. All rights reserved.
//

#import "ActivityCallUpViewController.h"
#import "CustomTableView.h"
#import "NetServiseCommonData.h"
#import "ActivityCallupDetailViewController.h"
#import "LaunchActivityViewController.h"
@interface ActivityCallUpViewController ()<CustomTabItemViewDelegate,CustomTableViewDelegate>

@property(nonatomic,strong) CustomTabItemView * tabItemView;
@property(nonatomic,strong) CustomTableView* actTableView;
@property(nonatomic,strong) NSArray* dataSource;
@end

@implementation ActivityCallUpViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setTitleView:@"活动召集令"];
    [self setRightButton:@"发起" sel:@selector(launch:) viewController:self];
    
    self.view.backgroundColor = COLOR_RGB(223, 223, 223);
    self.tabItemView = [[CustomTabItemView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 45) type:TAB_ITEM_TYPE_CORWIDTH];
    self.tabItemView.backgroundColor = [UIColor whiteColor];
    self.tabItemView.delegate = self;
    [self.tabItemView initWithBackColorCornerItemNames:@[@"最新活动",@"我报名的",@"我发起的"]];
    [self.view addSubview:self.tabItemView];
    
    _actTableView = [[CustomTableView alloc] initWithFrame:CGRectMake(0, self.tabItemView.bottom +5, SCREEN_WIDTH, SCREEN_HEIGHT - self.tabItemView.height - kTabBarHeight - 15) type:TABLE_VIEW_TYPE_ACTIVITYCALLUPLIST];
    _actTableView.tableViewDelegate = self;
    [self.view addSubview:_actTableView];
    
    
    
    [self startOfflineData];
}

-(void)startOfflineData{
    
    NSDictionary* dic = [NetServiseCommonData getActivityCallupListData];
    _dataSource = [dic objectForKey:@"list"];
    [_actTableView setTableViewDataSource:_dataSource];
}

#pragma tableviewdidselect
-(void)tableViewSelectedWithCellData:(id)cellData indexPath:(NSIndexPath *)indexPath tableView:(CustomTableView *)tableView{
    
    ActivityCallupDetailViewController* activityDetail = [[ActivityCallupDetailViewController alloc] init];
    [self.navigationController pushViewController:activityDetail animated:YES];
}

//发起
-(void)launch:(UIButton*)button{
    
    LaunchActivityViewController* launch = [[LaunchActivityViewController alloc] init];
    [self.navigationController pushViewController:launch animated:YES];
}

#pragma mark CustomTabItemViewDelegate
- (void)tabItemSelectedAtIndex:(int)index tabItem:(CustomTabItemView *)view
{
    
}
//
//- (void)tableViewRefreshFirstPage:(BaseUITableView *)tableView
//{
//    [self.actTableView performSelector:@selector(endRefreshing) withObject:nil afterDelay:2];
//}
//
//- (void)getMoreData:(BaseUITableView *)tableView
//{
//    if (self.isLoadMoreData) {
//        [self startOfflineData];
//        self.isLoadMoreData = YES;
//    }
//    
//}


- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    ;
}


- (void)viewWillDisappear:(BOOL)animated
{
    
    [super viewWillDisappear:animated];
    
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
